﻿using System.Threading.Tasks;
using RotovapPlatform.Domain.Common;

namespace RotovapPlatform.Domain.Equipment.DeviceParameters
{
	/// <summary>
	/// 设备参数服务接口
	/// </summary>
	public interface IDeviceParameterService
	{
		/// <summary>
		/// 获取当前设备参数
		/// </summary>
		/// <returns>设备参数</returns>
		Task<DeviceParametersEntity> GetParametersAsync();

		/// <summary>
		/// 保存设备参数
		/// </summary>
		/// <param name="parameters">设备参数</param>
		/// <returns>操作结果</returns>
		Task<OperationResult> SaveParametersAsync(DeviceParametersEntity parameters);

		/// <summary>
		/// 重置为默认参数
		/// </summary>
		/// <returns>操作结果</returns>
		Task<OperationResult> ResetToDefaultAsync();

		/// <summary>
		/// 导出参数到文件
		/// </summary>
		/// <param name="filePath">文件路径</param>
		/// <returns>是否成功</returns>
		Task<bool> ExportParametersAsync(string filePath);

		/// <summary>
		/// 从文件导入参数
		/// </summary>
		/// <param name="filePath">文件路径</param>
		/// <returns>是否成功</returns>
		Task<bool> ImportParametersAsync(string filePath);

		/// <summary>
		/// 获取电机参数
		/// </summary>
		/// <param name="motorId">电机ID</param>
		/// <returns>电机参数</returns>
		Task<Motor> GetMotorAsync(string motorId);

		/// <summary>
		/// 获取泵参数
		/// </summary>
		/// <param name="pumpId">泵ID</param>
		/// <returns>泵参数</returns>
		Task<Pump> GetPumpAsync(string pumpId);

		/// <summary>
		/// 获取传感器参数
		/// </summary>
		/// <param name="sensorId">传感器ID</param>
		/// <returns>传感器参数</returns>
		Task<Sensor> GetSensorAsync(string sensorId);

		/// <summary>
		/// 获取工艺参数
		/// </summary>
		/// <param name="parameterName">参数名称</param>
		/// <returns>工艺参数</returns>
		Task<ProcessParameter> GetProcessParameterAsync(string parameterName);

		/// <summary>
		/// 清除缓存的参数，强制下次从文件重新加载
		/// </summary>
		/// <returns>任务</returns>
		Task ClearCacheAsync();

		/// <summary>
		/// 参数更新事件
		/// </summary>
		event EventHandler<EventArgs> ParametersUpdated;
	}
}